Keyboard Class
Controls keyboard input
Constructor
Item Index
Properties
- _clearSq
- game
- KEY static
- sequence
- sequenceTimeout
Methods
_clearSequence
()
private
Clears the current sequence so that a new one can start
_getEventData
-
event -
down
Generates an event data object for a keyboard event
Parameters:
-
eventDOMEventThe original DOMEvent that was passed into the raw event handler
-
downBooleanIs this a keydown event
Returns:
The event object
emit
-
type -
data
Emits an event which will run all registered listeners for the event type
Parameters:
-
typeStringThe event name to emit
-
dataMixedAny data you want passed along with the event
Returns:
Returns itself.
modifyKey
-
event -
key -
down
Called when a key state has changed, updates current sequence and emits events
Parameters:
-
eventDOMEvent -
keyNumberThe key code that has changed
-
downBooleanWhether the key has been pressed or not
off
-
type -
listener
Removes a listener function for an event type
Parameters:
-
typeStringThe event name to emit
-
listenerFunctionThe function to remove
Returns:
Returns itself.
on
-
type -
listener
Registers a listener function to be run on an event occurance
Parameters:
-
typeStringThe event name to listen for
-
listenerFunctionThe function to execute when the event happens
Returns:
Returns itself.
once
-
type -
listener
Registers a one-time callback for an event
Parameters:
-
typeStringThe event name to listen for
-
listenerFunctionthe callback to call when the event occurs
Returns:
Returns itself.
onKeyDown
-
event -
override
Called when a key is pressed down
Parameters:
-
eventDOMEvent -
overrideNumberThe key code to use instead of checking event data
onKeyUp
-
event -
override
Called when a key is released
Parameters:
-
eventDOMEvent -
overrideNumberThe key code to use instead of checking event data
Properties
_clearSq
Number
private
The timeout ID for the wait to clear the input sequence
KEY
Object
static
Bindable keycodes
sequence
ArrayThe current sequence of keys that have been pressed
sequenceTimeout
Number
The amount of time it takes for the sequence to clear out, in ms
Default: 500